package org.jsola.hr.helper;

import org.jsola.hr.constant.EmpInfoRequireType;
import org.jsola.hr.constant.EmpInfoScene;
import org.jsola.hr.dto.EmpEducationRequireAddDTO;
import org.jsola.hr.dto.EmpEducationRequireUpdateDTO;
import org.jsola.hr.entity.EmpEducationRequireDO;
import org.jsola.hr.query.EmpEducationRequireQuery;
import org.jsola.hr.service.IEmpEducationRequireService;
import org.jsola.hr.vo.EmpEducationRequireVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * @author zhr
 */
@Component
public class EmpEducationRequireTestHelper extends BaseTestHelper {

    @Autowired
    private IEmpEducationRequireService empEducationRequireService;

    /**
     * 生成add测试数据
     * @return EmpEducationRequireAddDTO
     */
    public EmpEducationRequireAddDTO getEmpEducationRequireAddDTO(){
        EmpEducationRequireAddDTO empEducationRequireAddDTO = new EmpEducationRequireAddDTO();
        empEducationRequireAddDTO.setCompanyId(getRandomValue("varchar",32));
        empEducationRequireAddDTO.setRequireType(EmpInfoScene.ENTRY.getValue());
        empEducationRequireAddDTO.setGraCollege(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setIsLehramt(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setMajor(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setEducation(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setTeaMethods(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setStartTime(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setEndTime(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setIsFirstEdu(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setIsHighestEdu(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setDegreeName(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setIsFirstDegree(EmpInfoRequireType.NO_NEED.getValue());
        empEducationRequireAddDTO.setIsHighestDegree(EmpInfoRequireType.NO_NEED.getValue());
        return empEducationRequireAddDTO;
    }


    /**
     * 生成update测试数据
     * @return EmpEducationRequireUpdateDTO
     */
    public EmpEducationRequireUpdateDTO getEmpEducationRequireUpdateDTO(EmpEducationRequireVO empEducationRequireVO){
        return empEducationRequireService.selectDOById(empEducationRequireVO.getId(), SITE_ID).to(EmpEducationRequireUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return EmpEducationRequireQuery
     */
    public EmpEducationRequireQuery getEmpEducationRequireQuery() {
        EmpEducationRequireQuery empEducationRequireQuery = new EmpEducationRequireQuery();
        List<EmpEducationRequireDO> empEducationRequireDOList = empEducationRequireService.list(new EmpEducationRequireDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(empEducationRequireDOList)) {
            EmpEducationRequireDO empEducationRequireDO = empEducationRequireDOList.get(0);
            empEducationRequireQuery = empEducationRequireDO.to(EmpEducationRequireQuery.class);
        }
        return empEducationRequireQuery;
    }

    /**
     * 保存示例
     * @return EmpEducationRequireVO
     */
    public EmpEducationRequireVO saveEmpEducationRequireExample(){
        EmpEducationRequireAddDTO addDTO = this.getEmpEducationRequireAddDTO();
        EmpEducationRequireVO empEducationRequireVO = empEducationRequireService.save(addDTO,buildTokenUser());
        return empEducationRequireVO;
    }


}

